package cn.ghostcloud.demo4.controller;

import cn.ghostcloud.demo4.common.core.domain.R;
import cn.ghostcloud.demo4.common.core.domain.req.GenDTEDReq;
import cn.ghostcloud.demo4.common.core.domain.req.GetProgressReq;
import cn.ghostcloud.demo4.service.GenerateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.io.FileNotFoundException;

@RestController
@Tag(name = "高程数据生成服务")
@RequestMapping("/api/generate")
public class GenerateController {
    @Resource
    private GenerateService generateService;
    @PostMapping("/genDTED")
    @Operation(summary = "生成高程数据")
    public R upload(@RequestBody GenDTEDReq genDTEDReq) throws InterruptedException {
        return R.ok(generateService.genDTED(genDTEDReq));
    }

    @PostMapping("/getProgress")
    @Operation(summary = "获取生成进度")
    public R getProgress(@RequestBody GetProgressReq getProgressReq) throws FileNotFoundException, InterruptedException {
        return R.ok(generateService.getProgress(getProgressReq));
    }

    @GetMapping("/getProgress")
    @Operation(summary = "停止生成")
    public R stop(@RequestParam String uuid) throws InterruptedException {
        generateService.stopGenerate(uuid);
        return R.ok();
    }
}
